home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: 76623,2065@compuserve.com (Bobby Martin)
- Newsgroups: comp.lang.c++
- Subject: Re: Trig functions
- Date: 5 Jan 1996 15:15:45 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4cjfb1$fco@dub-news-svc-4.compuserve.com>
- References: <4ch9ka$4pc@felix.junction.net>
- Reply-To: 76623,2065@compuserve.com (Bobby Martin)
- NNTP-Posting-Host: dd24-036.compuserve.com
- X-Newsreader: IBM NewsReader/2 v1.03
-
- In <4ch9ka$4pc@felix.junction.net>, heppner@portage.net (Donald Heppner) writes:
- >I need to have a few trig functions in my C++ program. I have found
- >some trig functions, but for some reason, they give the wrong answer
- >(Maybe a different kind of trig). I need tan, cos, sin, and all of these
- >functions to the power of negative one. I need them to give me the same
- >answer as a calculator would.
- >
- >Thanks
- >Donald
- The problem is probably that the standard C library trig functions require
- the angle in radians and you're giving degrees. Just multiply the number
- you're giving the function by pi/180, where pi is approximately 3.14159.
- i.e. instead of
- x = pow( sin( 3*b+30 ), -1 );
- use this
- const float pi=3.14159
- ..
- x = pow( sin( (3*b+30) * pi / 180 ), -1 );
-
-
- Hope that helps.
-